package tree;

import java.util.HashMap;
import java.util.Map;

public class _0718_前后遍历构建二叉树 {

    int preIndex = 0;
    int postIndex = 0;

    public TreeNode buildTree(int[] preorder, int[] postorder) {
        int val = preorder[preIndex++];
        TreeNode root = new TreeNode(val);
        if (val != postorder[postIndex]) {
            root.left = buildTree(preorder, postorder);
        }
        if (val != postorder[postIndex]) {
            root.right = buildTree(preorder,postorder);
        }
        postIndex++;
        return root;
    }


}
